package com.ruoyi.web.controller.jiugongge;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.jiugongge.domain.JiugonggeRecord;
import com.ruoyi.jiugongge.service.IJiugonggeRecordService;
import com.ruoyi.framework.web.base.BaseController;
import com.ruoyi.common.page.TableDataInfo;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.base.AjaxResult;

/**
 * 九宫格抽奖记录 信息操作处理
 * 
 * @author lzy
 * @date 2019-02-20
 */
@Controller
@RequestMapping("/jiugongge/jiugonggeRecord")
public class JiugonggeRecordController extends BaseController
{
    private String prefix = "jiugongge/jiugonggeRecord";
	
	@Autowired
	private IJiugonggeRecordService jiugonggeRecordService;
	
	@RequiresPermissions("jiugongge:jiugonggeRecord:view")
	@GetMapping()
	public String jiugonggeRecord()
	{
	    return prefix + "/jiugonggeRecord";
	}
	
	/**
	 * 查询九宫格抽奖记录列表
	 */
	@RequiresPermissions("jiugongge:jiugonggeRecord:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(JiugonggeRecord jiugonggeRecord)
	{
		startPage();
        List<JiugonggeRecord> list = jiugonggeRecordService.selectJiugonggeRecordList(jiugonggeRecord);
		return getDataTable(list);
	}
	
	
	/**
	 * 导出九宫格抽奖记录列表
	 */
	@RequiresPermissions("jiugongge:jiugonggeRecord:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(JiugonggeRecord jiugonggeRecord)
    {
    	List<JiugonggeRecord> list = jiugonggeRecordService.selectJiugonggeRecordList(jiugonggeRecord);
        ExcelUtil<JiugonggeRecord> util = new ExcelUtil<JiugonggeRecord>(JiugonggeRecord.class);
        return util.exportExcel(list, "jiugonggeRecord");
    }
	
	/**
	 * 新增九宫格抽奖记录
	 */
	@GetMapping("/add")
	public String add()
	{
	    return prefix + "/add";
	}
	
	/**
	 * 新增保存九宫格抽奖记录
	 */
	@RequiresPermissions("jiugongge:jiugonggeRecord:add")
	@Log(title = "九宫格抽奖记录", businessType = BusinessType.INSERT)
	@PostMapping("/add")
	@ResponseBody
	public AjaxResult addSave(JiugonggeRecord jiugonggeRecord)
	{		
		return toAjax(jiugonggeRecordService.insertJiugonggeRecord(jiugonggeRecord));
	}

	/**
	 * 修改九宫格抽奖记录
	 */
	@GetMapping("/edit/{id}")
	public String edit(@PathVariable("id") String id, ModelMap mmap)
	{
		JiugonggeRecord jiugonggeRecord = jiugonggeRecordService.selectJiugonggeRecordById(id);
		mmap.put("jiugonggeRecord", jiugonggeRecord);
	    return prefix + "/edit";
	}
	
	/**
	 * 修改保存九宫格抽奖记录
	 */
	@RequiresPermissions("jiugongge:jiugonggeRecord:edit")
	@Log(title = "九宫格抽奖记录", businessType = BusinessType.UPDATE)
	@PostMapping("/edit")
	@ResponseBody
	public AjaxResult editSave(JiugonggeRecord jiugonggeRecord)
	{		
		return toAjax(jiugonggeRecordService.updateJiugonggeRecord(jiugonggeRecord));
	}
	
	/**
	 * 删除九宫格抽奖记录
	 */
	@RequiresPermissions("jiugongge:jiugonggeRecord:remove")
	@Log(title = "九宫格抽奖记录", businessType = BusinessType.DELETE)
	@PostMapping( "/remove")
	@ResponseBody
	public AjaxResult remove(String ids)
	{		
		return toAjax(jiugonggeRecordService.deleteJiugonggeRecordByIds(ids));
	}
	
}
